package net.wds.ssbus.modules.dbconfig.controller;

import java.util.Arrays;
import java.util.Map;

import net.wds.ssbus.common.utils.PageUtils;
import net.wds.ssbus.common.utils.R;
import net.wds.ssbus.modules.dbconfig.entity.TbDbSourceEntity;
import net.wds.ssbus.modules.dbconfig.po.DbSourceConfigPo;
import net.wds.ssbus.modules.dbconfig.service.TbDbSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 数据源 
 *
 * @author qsg
 * @email qsg@wdsrouce
 * @date 2020-10-22 11:41:56
 */
@RestController
@RequestMapping("dbconfig/tbdbsource")
public class TbDbSourceController {
    @Autowired
    private TbDbSourceService tbDbSourceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("ssbus:tbdbsource:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbDbSourceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("ssbus:tbdbsource:info")
    public R info(@PathVariable("id") Integer id){
		TbDbSourceEntity tbDbSource = tbDbSourceService.getById(id);

        return R.ok().put("tbDbSource", tbDbSource);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ssbus:tbdbsource:save")
    public R save(@RequestBody DbSourceConfigPo dbSourceConfigPo){
		tbDbSourceService.saveSource(dbSourceConfigPo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("ssbus:tbdbsource:update")
    public R update(@RequestBody DbSourceConfigPo dbSourceConfigPo){
		tbDbSourceService.updateSourceById(dbSourceConfigPo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("ssbus:tbdbsource:delete")
    public R delete(@RequestBody Integer[] ids){
		tbDbSourceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
